<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>{$activityname}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
<link href="{$Think.config.RESOURCEURL}wx_assets/love/love.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
<style type="text/css">
    .data-end{
        position: relative;
        z-index: 1;
        margin-top: -55px;
        line-height: 55px;
    }
</style>
</head>
<body>
<div class="cipher">设置暗号</div>
<div id="regBox" class="regboxs">
    <div class="titleone"><input class="questions" type="text" id="question" value="{$regInfo.question}"  placeholder="例如 : 天王盖地虎"></div>
    <div class="titleone"><input class="questions answer" type="text" id="answer"  value="{$regInfo.answer}" placeholder="例如 : 宝塔镇妖河"></div>
</div>
<div style="margin:0 10px">
    <a class="bg-common answer-btn js-btn submit" data-event="_save" data-normal="{$jsonstr.ANSWER_BUTTON_TIJIAO.src}" id="SaveBtn"  data-click="{$jsonstr.ANSWER_BUTTON_TIJIAO_CLICK.src}" style="background-image:url({$jsonstr.ANSWER_BUTTON_TIJIAO.src}); ">&nbsp;</a>
    <img id="ANSWER_BUTTON_TIJIAO" src="{$jsonstr.ANSWER_BUTTON_TIJIAO_CLICK.src}" style="display:none">
</div>
    <div class="noanh" id="SaveBtn1">不设置暗号、直接送>></div>

    <script type="text/javascript">
    var baseUrl = '{$Think.config.SERVER_HOST}';
    var page={
        init:function(){
            var me=this;
            this.initButtonState();
            $("#SaveBtn1").click(function(){
                me._goNext();
            });
            this._initValidate();
        },
        _goNext:function(){
            var uParam=$.util.getParamAsObject();
            var params={
                "actId":"{$actId}",
                "regId":"{$regId}",
                "qId":uParam.qId,
                "miUId":uParam.miUId,
                "fromGuid":uParam.fromGuid || ""
            }
            params=encodeURIComponent(JSON.stringify(params));
            location.href= 'call.html?customerId={$customerId}&module=love&method=view&params='+params;
        },
        _save:function(){
            var p=$.util.getParamAsObject();
            var me=this;
            p.regId="{$regId}";
            $.extend(p,{
                "question": $.trim($("#question").val()),
                "answer": $.trim($("#answer").val())
            });
            $.util.pageLoading.show();
            $.req.get("call.json?customerId={$customerId}&module=love&method=saveAnswer",{
                userName:"{$userName}",
                params:p
            },function(data){
                $.util.pageLoading.hide();
                if(!data.code){
                   me._goNext();
                } else {
                    $.util.alert(data.msg);
                }
            });
        },
        _initValidate:function(){
             var me = this;
            $("#SaveBtn").click(function() {
                if(!$("#question").val()){
                    $.util.alert("请输入暗号");
                    return false;
                }
                if(!$("#answer").val()){
                    $.util.alert("请输入答案");
                    return false;
                }
                me._save();
            });
        },
        initButtonState:function(){
            var me=this;
            $(".js-btn").click(function(){
                var clickUrl=$(this).data("click");
                var normalUrl=$(this).data("normal");
                var eventName=$(this).data("event");
                $(this).css("background-image","url("+clickUrl+")");
                var btn=this;
                setTimeout(function(){
                    $(btn).css("background-image","url("+normalUrl+")");
                },100);
            });
        }
    }
    page.init();
    </script>
</body>
</html>